<?php
class ModelCatalogNotice extends Model {
	
	
	public function getNotice($notice_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "notice i LEFT JOIN " . DB_PREFIX . "notice_description id ON (i.notice_id = id.notice_id) LEFT JOIN " . DB_PREFIX . "notice_to_store i2s ON (i.notice_id = i2s.notice_id) WHERE i.notice_id = '" . (int)$notice_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");
	
		return $query->row;
	}
	
	public function getNotices($start,$end) {
		$start =($start-1)*$end;
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "notice i LEFT JOIN " . DB_PREFIX . "notice_description id ON (i.notice_id = id.notice_id) LEFT JOIN " . DB_PREFIX . "notice_to_store i2s ON (i.notice_id = i2s.notice_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' AND i.sort_order <> '-1' ORDER BY i.sort_order, LCASE(id.title) ASC LIMIT $start, $end ");
		
		return $query->rows;
	}
	
	public function getNumNotices() {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "notice i LEFT JOIN " . DB_PREFIX . "notice_description id ON (i.notice_id = id.notice_id) LEFT JOIN " . DB_PREFIX . "notice_to_store i2s ON (i.notice_id = i2s.notice_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' AND i.sort_order <> '-1' ORDER BY i.sort_order, LCASE(id.title) ASC");
		
		return $query->num_rows;
	}
	
	
	
	
}
?>